using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameApp : UnitySingleton<GameApp>
{
    public void Init()
    {
    }

    public IEnumerator EnterGame()
    { // 进入游戏
        Debug.Log("EnterGame ...");

        yield return this.TestGame();

        Debug.Log("End Game");
        yield break;
    }

    IEnumerator TestGame()
    {
        // 测试同步资源加载
        /*TextAsset t = ResMgr.Instance.LoadAssetSync<TextAsset>("Datas/fragment");
        Debug.Log(t.text);
        */
        // end


        // 异步加载资源
        /*var h = ResMgr.Instance.LoadAssetAsync<TextAsset>("Datas/fruit.csv");
        yield return h;
        t = h.AssetObject as TextAsset;
        h.Dispose();
        Debug.Log(t.text);*/
        // end

        // 测试场景加载
        // yield return SceneMgr.Instance.IE_RunScene("Scenes/main.unity");
        //SceneMgr.Instance.RunScene("Scenes/main.unity");
        // end
        /*
        // 测试Log日志
        Debugger.Log("test 1");
        Debugger.Log("test 2");
        Debugger.Log("test 3");
        Debugger.Log("test 4");
        Debugger.Log("test 5");
        */

        /*
        // 事件触发测试
        EventMgr.Instance.AddListener("test", this.OnTestCall);
        EventMgr.Instance.RemoveListener("test", this.OnTestCall);
        EventMgr.Instance.Emit("test", 77777);
        */

        /*
        // Timer测试
        TimerMgr.Instance.ScheduleOnce((object udata)=> {
            Debug.Log("one time ####");
        }, 5f);

        int timerID = TimerMgr.Instance.Schedule((object udata) => {
            Debug.Log("repeat time ####");
        }, -1, 1f, 5f);


        TimerMgr.Instance.ScheduleOnce((object udata) => {
            Debug.Log("cancel time ####");
            TimerMgr.Instance.UnShedule(timerID);
        }, 10f);
        // end
        */

        // 测试声音
        //SoundMgr.Instance.PlayOneShot("Sounds/bestReward");
        // end

        yield break;
    }

    /*private void OnTestCall(string uname, object udata) {
        Debug.Log("OnTestCall");
        Debug.Log(udata);
    }*/
}
